package com.tianyang.yukuaifu.business.main.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.tianyang.yukuaifu.R;
import com.tianyang.yukuaifu.base.BaseTitleActivity;
import com.tianyang.yukuaifu.business.main.bean.HelpCenterOutput;
import com.tianyang.yukuaifu.business.main.contract.HelpCenterContract;
import com.tianyang.yukuaifu.business.main.presenter.HelpCenterPresenter;
import com.tianyang.yukuaifu.utils.VerifyUtil;

import butterknife.BindView;

/**
 * Description：帮助中心
 * Created by xyj on 2024/3/11
 */
public class HelpCenterActivity extends BaseTitleActivity implements HelpCenterContract.View {

    @BindView(R.id.serviceTimeTv)
    TextView serviceTimeTv;
    @BindView(R.id.servicePhoneTv)
    TextView servicePhoneTv;
    @BindView(R.id.serviceCodeSdv)
    SimpleDraweeView serviceCodeSdv;

    private HelpCenterContract.Presenter mPresenter;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_help_center;
    }

    @Override
    protected void initView() {
        super.initView();
        commonTitle.setTitle("帮助中心");
        mPresenter = new HelpCenterPresenter(this);
        mPresenter.getServicePhone();
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void showServicePhoneView(HelpCenterOutput output) {
        if (output != null) {
            serviceTimeTv.setText("客服在线时间：" + VerifyUtil.checkString(output.getServiceTime()));
            servicePhoneTv.setText("客服热线：" + VerifyUtil.checkString(output.getServicePhone()));
            if (!TextUtils.isEmpty(output.getServiceCodeUrl()))
                serviceCodeSdv.setImageURI(Uri.parse(output.getServiceCodeUrl()));
        }
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }

    @Override
    public void setPresenter(HelpCenterContract.Presenter presenter) {
        this.mPresenter = presenter;
    }

    @Override
    public Context getContext() {
        return this;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.onDestroyPresenter();
            mPresenter = null;
        }
     }
}
